<template>
	<view class="container">
		<navBar title="施工条件验收审核" @goBack="uni.navigateBack()"></navBar>
		
		<view class="examination-approval-list" :style="{height: `calc(100% - ${systemInfo.navbarHeight}px - ${systemInfo.stateHeight}px)`}">
			<view class="search-content">
				<view class="search">
					<u-icon name="search" color="#a7aebd" size="26"></u-icon>
					 <u--input @confirm="search" v-model="keyword" placeholder="请输入关键字" border="surround" clearable :customStyle="{border: 'none'}"></u--input>
				</view>
			</view>
			
			<scroll-view @scrolltolower="scrolltolower" class="scroll-view" scroll-y>
				<view>
					<view v-for="(item, index) in constructionPlanList" :key="index" class="item-content">
						<view class="title">
							<view class="state orange">待审核</view>
							<view class="text-overflow">{{ item.pmName }}</view>
						</view>
						<view class="date">
							<u-icon name="clock" color="#6a819e" size="14"></u-icon>
							<view class="date-text">提交时间：{{ item.recordCreateDate }} | {{ item.creatorUserName }}</view>
						</view>
						<view class="label">线路名称：{{ item.lineSiteName }}</view>
						<view class="label">区间站点：{{ item.siteName }}</view>
						<view class="label">现场带班负责人：{{ item.onSiteShiftLeaderName }}</view>
						<view class="btn-content">
							<view @click="checkProjectDetails(item)" class="gray">计划详情</view>
							<view @click="examineItem(item)" class="blue">审核</view>
						</view>
					</view>
					<u-empty v-if="!constructionPlanList.length" mode="data" text="数据为空" icon="http://cdn.uviewui.com/uview/empty/data.png"></u-empty>
				</view>
			</scroll-view>
		</view>	
	</view>
</template>

<script>
	import { getConstructionPlanList } from "@/api/conditionalAcceptance/constructionPlan.js"
	import { handleFormatDate } from "@/utils/date.js"
	import { getSystemHeightInfo } from "@/utils/common.js"
	export default {
		data() {
			return {
				paging: {
					pageNum: 1,
					pageSize: 10,
					total: 0,
				},
				keyword: '',
				systemInfo: {},
				constructionPlanList: []
			}
		},
		onShow() {
			this.systemInfo = getSystemHeightInfo()
			this.search()
		},
		methods: {
			search() {
				this.constructionPlanList = []
				this.paging.pageNum = 1
				this.getConstructionPlanArray()
			},
			scrolltolower() {
				if (this.paging.pageNum * this.paging.pageSize < this.paging.total) {
					this.paging.pageNum++
					this.getConstructionPlanArray()
				}
			},
			checkProjectDetails(data) {
				uni.navigateTo({ url: "/subpackage-enginner/pages/engineeringMaintenance/conditionalAcceptance/projectDetails?state=2&id=" + data.id })
			},
			examineItem(data) {
				uni.navigateTo({ url: "/subpackage-enginner/pages/engineeringMaintenance/conditionalAcceptance/conditionalAcceptanceDetails?type=7&id=" + data.id  })					
			},
			getConstructionPlanArray() {
				const { pageNum, pageSize } = this.paging
				getConstructionPlanList({
					currPage: pageNum,
					pageSize,
					projectId: null,
					params: {
						orderStatusList: ['acceptance_status_audit'],
						keyword: this.keyword,
						state:1,
						projectId: null
					}
				}).then(res => {
					if (res && res.result && res.result.list) {
						this.constructionPlanList = this.constructionPlanList.concat(res.result.list.map(item => {
							const siteNames = []
							for (const item1 of item.lineSiteList) {
								for (const item2 of item1.list) {
									for (const item3 of item2.list) {
										siteNames.push(item3.name)
									}
								}
							}
							return {
								...item,
								recordCreateDate: item.recordCreateDate ? handleFormatDate(new Date(item.recordCreateDate), 3) : '',
								lineSiteName: item.lineSiteList.map(item1 => item1.name).join("、"),
								siteName: siteNames.join("、")
							}
						}))
						this.paging.total = res.result.total
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.container {
		box-sizing: border-box;
		height: 100vh;
		overflow: hidden;
		/* #ifdef MP-WEIXIN */
		padding-top: 200rpx;
		/* #endif */
	}
	.examination-approval-list {
		box-sizing: border-box;
		border-top: 15px solid #f5f7fa;
		background: #fff;
		font-size: 16px;
		height: 100%;
		.text-overflow {
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
		}
		.search-content {
			height: 69px;
			padding: 0 8px 0 14px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.search {
				display: flex;
				align-items: center;
				background: #f5f7fa;
				border-radius: 25px;
				margin-right: 6px;
				padding: 10px 12px;
				box-sizing: border-box;
				height: 44px;
				line-height: 44px;
				flex: 1;
			}
		}
		.scroll-view {
			height: calc(100% - 15px - 69px);
			border-top: 12px solid #f5f7fa;
			box-sizing: border-box;
			padding: 0 14px;
			.item-content {
				// height: 202px;
				height: 231px;
				padding: 14px 12px 14px;
				border-bottom: 1px solid #E3E5E8;
				box-sizing: border-box;
				.title {
					height: 28px;
					line-height: 28px;
					display: flex;
					align-items: center;
					.state {
						border-radius: 0 4px 0 4px;
						font-weight: bold;
						padding: 0 4px;
						line-height: 22px;
						margin-right: 12px;
						flex-shrink: 0;
						color: #fff;
						font-size: 14px;
						&.orange {
							background: #ff8a2c;
						}
					}
					.text-overflow {
						flex: 1;
						color: #445469;
						font-weight: bold;
					}
				}
				.date {
					height: 20px;
					line-height: 20px;
					padding: 10px 0 9px;
					color: #6a819e;
					display: flex;
					align-items: center;
					font-size: 13px;
					.date-text {
						margin-left: 3px;
						white-space: nowrap;
						text-overflow: ellipsis;
						overflow: hidden;
						width: calc(100% - 20px);
					}
				}
				.label {
					line-height: 29px;
					color: #6f747b;
					font-weight: bold;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
					font-size: 14px;
				}
				.btn-content {
					display: flex;
					align-items: center;
					font-weight: 500;
					margin-top: 15px;
					text-align: center;
					font-size: 14px;
					> view {
						line-height: 34px;
						width: 100px;
						margin-right: 11px;
						border-radius: 50px;
					}
					.gray {
						color: #445469;
						background: #f5f7fa;
					}
					.blue {
						color: #fff;
						background: #2f80ed;
					}
				}
			}
		}
	}
</style>
